<div style="text-align:center;margin-bottom:20px;padding:20px 5px;border:1px dashed #FF9A9A;">
	
	<?php if(!$can_view){?>
		<div onclick='buy(1,"<?php echo $goods['shop_price'];?>")' style="margin-bottom:20px;">
			<img src="__STATIC__mobile/img/kde_folder_locked.png">
			<div>内容已隐藏</div>
			<div>当前内容属于VIP专属内容</div>
			<div>如需查看隐藏内容,请先购买成为VIP</div>
		</div>
	<?php } ?>

	<div class="vote-select" style="margin:10px;">
		<a  class="reward_access" href="/mobile/goods/index/?goods_id=<?php echo $goods['goods_id'];?>" style="color: #fff;"><?php echo $article['buy_btn'];?></a>
	</div>


</div>





<script>

//创建支付信息"  
function createpay(gid){
	
	var url = "/mobile/order/createpay";
	
	var goods_id = new Array();//商品id
	goods_id[0] = gid;
//	console.log(gid);
//	console.log(goods_id);
//	return false;
	
	var num = "1";//商品数量,多个用逗号,隔开
	var delivery_name = "<?php echo $memberinfo['realname'] ? $memberinfo['realname'] : $memberinfo['nickname'];?>";//收货人
	var delivery_mobile = $("#delivery_mobile").val();//手机号
	var wechat_user = "<?php echo $memberinfo['wechat_id'];?>";//微信号
	
	//判断手机号是否正确
	if(!isMobile(delivery_mobile)){

			layer.open({
				content: "请输入正确的手机号码",
				style: 'background-color:#ef4f4f; color:#fff; border:none;text-align:center;font-size:16px;',
				type: 2,
				time:2
			});
		

		return false;
	}
	
	if(delivery_name == ''){
		delivery_name = "<?php echo $memberinfo['realname'];?>";
	}
	
	
	$.ajax({
		url : url,
		type : "POST",
		dataType : 'json',
		data:{'checkbox':goods_id,"num":num,"delivery_name":delivery_name,"delivery_mobile":delivery_mobile,"wechat_user":wechat_user},
		success : function(data) {
			//关闭正在加载
			 layer.closeAll();//关闭所有
			if(data.url){
				var urls = data.url;
			}else{
				var urls = '';
			}

			if(data.ret == 0){
				// 成功
				var order_id = data.url;
				jsApiCall(data.data,order_id);
			}else{
				// 失败
				showerror(data.msg,urls);
			}
		},
		beforeSend:function(){
			//正在加载
			layer.open({
		        type: 2,
		        shade: true,
		        shadeClose: false,
		    });
			
       },
       error: function() {
		   //关闭正在加载
    	   layer.closeAll();//关闭所有
		   showerror("网络错误,请重试");
       }
       
	});
	
}



//购买输入信息
function buy(goods_id,money){
	//alert(goods_id);
	var txt = '<span class="buyinput">'+
	'<input type="tel"  maxlength="11" value="<?php echo $memberinfo['mobile'];?>" id="delivery_mobile" name="mobile" placeholder="*请输入您的手机号码">'+
			'<a href="javascript:createpay('+goods_id+');" class="mbtn btn-success btn-big ">立即报名<span style="font-size:12px;">(微信支付'+money+'元)</span></a></span>';
	//信息框
	layer.open({
	    title: ['请输入您的手机号码','font-weight:bold; color:#fff;'],
	    content: txt,
	  //  shadeClose: false,//点击遮罩不关闭对话框
	    style: 'color:#fff;width:92%;max-width: 350px;background-color:#ea3b26;  background: url(/Static/mobile/img/ad.png) no-repeat;background-size:100%;',
	});
	
}


function jsApiCall(jsparam,order_id)
{
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		jsparam,
		function(res){
		//	alert(res.err_msg);
			WeixinJSBridge.log(res.err_msg);
			 if(res.err_msg == "get_brand_wcpay_request:ok" ) {
			 	//支付成功
			 	
				location.href = "/mobile/article?refresh=1&article_id=<?php echo $article['article_id'];?>&order_id="+order_id;
			 
			 }else if(res.err_msg == "get_brand_wcpay_request:cancel"){
				 
				//location.href = "/mobile/order/detail?order_id="+order_id;
				
			 }else{
				//location.href = "/mobile/order/detail?order_id="+order_id;
			 }

		}
	);
}

</script>